<!--
  To change this template, choose Tools | Templates
  and open the template in the editor.
-->

<%@ page contentType="text/html;charset=UTF-8" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Add an employee to the project</title>
    </head>
    <body>
        <div class="body">

          <!-- display only if the current mode allows it -->
          <g:if test="${Project.get(projectid).mode==2}">
            <g:btnMode mode="${session.mode}" currentView="add_employee" currentController="project" idProject="${projectid}"></g:btnMode>
          </g:if>
          <g:else>
            <div class="mode">
              <span style="font-weight:bold; padding-right:10px">
              <g:if test="${session.mode == null || session.mode.equalsIgnoreCase('sandbox')}">
                Sandbox mode
              </g:if>
              <g:else>
                Budget mode
              </g:else>
                </span>
            </div>
          </g:else>

          <h1>Add an employee to the project : ${Project.get(projectid).getName()}</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <form name ="addEmployee" action="/MegaSoft/project/save_added_employee" >
              <input type="hidden" name="projectid" value="${projectid}"/>
              <table>
                <thead>
                    <tr>
                        <th>Add</th>
                        <g:sortableColumn property="name" title="Name" />
                        <g:sortableColumn property="title" title="Title" />
                    </tr>
                </thead>
                <tbody>
                <g:each in="${employeeList}" status="i" var="employeeInstance">
                  <tr>
                    <td>
                      <input type="checkbox" name ="employeeid" value="${employeeInstance.id}" />
                    </td>
                    <td>
                      <g:link action="show" id="${employeeInstance.id}">${fieldValue(bean:employeeInstance, field:'firstName')}</g:link>
                      <g:link action="show" id="${employeeInstance.id}">${fieldValue(bean:employeeInstance, field:'lastName')}</g:link>
                    </td>
                    <td>
                      <g:link action="show" id="${employeeInstance.id}">${fieldValue(bean:employeeInstance, field:'title')}</g:link>
                    </td>
                  </tr>
                </g:each>
                </tbody>
              </table>
              <div class="buttons">
                  <span class="button">
                      <input type="submit" class="add_employee" value="Add employee(s)" name="Add employee"/>
                  </span>
             </div>
            </form>
        </div>
  </body>
</html>
